package com.gujiangbo.chapter06;

import java.util.concurrent.TimeUnit;

/**
 * @Author: gujiangbo.co
 * @Contact: 646832012@qq.com
 * @Date: 2022/3/28 21:12
 * @Version: 1.0
 * @Description:
 */
public class JavaHeapSpaceInital {

    public static void main(String[] args) {

        // 返回Java虚拟机中堆内存总量
        long initialMemory = Runtime.getRuntime().totalMemory() / 1024 / 1024;
        // 返回Java虚拟机试图使用的最大堆内存量
        long maxMemory = Runtime.getRuntime().maxMemory() / 1024 / 1024;

        System.out.println("-Xms ：" + initialMemory + "M");
        System.out.println("-Xmx ：" + maxMemory + "M");

        System.out.println("系统内存大小为：" + initialMemory * 64.0 / 1024 + "G");
        System.out.println("系统内存大小为：" + maxMemory * 4.0 / 1024 + "G");


        //暂停10秒钟线程
/*        try{
            TimeUnit.SECONDS.sleep(1000);} catch (InterruptedException e) {e.printStackTrace();}*/
    }
}
